package com.tan.demo1app.controller;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.tan.demo1app.dao.UserDAO;
import com.tan.demo1app.model.User;
 
/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {
     
    @Autowired
    private UserDAO userDao;
     
    @RequestMapping(value="/", method = RequestMethod.GET)
    public ModelAndView home() {
        List<User> listUsers = userDao.list();
        ModelAndView model = new ModelAndView("home");
        model.addObject("userList", listUsers);
        return model;
    }

    @RequestMapping(value="/test", method = RequestMethod.GET)
    public String test() {
        return "test";
    }
    
}